home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-04-15 | 3.1 KB | 87 lines | [TEXT/PJMM] |
- unit getHelp;
-
- {Procedure for Calling the Help desk accessory }
- {for Context Sensitive Help and Extended Alert Messages}
- {{Copyright ©1988 , Help Software , Inc . }
- { Modified by Dave Kelly for MacTutor, April 1989 }
- { Source code in Lightspeed Pascal 2.0 }
- { This procedure will open the Help DA and pass it the number }
- {of the Help message to be displayed . }
- { Under MultiFinder , this procedure will install the Help DA in * the }
- { application heap . }
-
- interface
-
- function main (message: integer): integer;
- { message: number of message to display }
-
-
- implementation
-
- function main (message: integer): integer;
-
- type
- LongPtr = ^LONGINT;
-
- var
- error, Help: integer; { Help is the desk accessory refnum }
- param: ParamBlockRec; { parameter block for the control call }
- myhandle: Handle;
- name: string;
- theKeyMap: longint;
- theKeyMapPtr: LongPtr;
-
- begin
- theKeyMap := $178;
- Help := 0;
- name := CONCAT(CHR(0), 'Help');
- SetResLoad(FALSE); { Don't load it,}
- myhandle := GetNamedResource('DRVR', name); { ...just get the handle }
- error := ResError; { -192 = Help not available }
- SetResLoad(TRUE); { Reset SetResLoad }
- if (error = noErr) then
- begin { Help is available}
- EmptyHandle(myhandle); { Try to purge the Help DA }
- if myhandle = nil then { If handle=NIL, it's not loaded, }
- begin
- ResrvMem(SizeResource(myhandle)); { ...reserve memory for it }
- error := MemError; { -108 = Not enough room in heap }
- end;
- if error = noErr then { all go .. . }
- begin
- LongPtr(theKeyMap)^ := BitOr(LongPtr(theKeyMap)^, 4);
- { Required to work properly with MultiFinder }
- { Press the Option key }
- Help := OpenDeskAcc(name); { Open the Help DA }
-
- if (Help < 0) and (Help = (WindowPeek(FrontWindow)^.windowKind)) then
-
- { If the Help DA open }
- begin
- param.ioCompletion := nil;
- param.ioRefNum := Help; { Help is the value returned}
- { by the OpenDeskAcc call }
- param.csCode := 5000; { 5000 tells the Help DA: "This is}
- {a context sensitive help call" }
- param.csParam[0] := message; { Help message to display }
- error := PBControl(@param, TRUE);
- { An asynchronous control call that tells the Help DA what to show ! }
- end { end if Is the Help DA open }
- else
- begin
- error := 1; { Let the caller know that the Help DA was not opened }
- LongPtr(theKeyMap)^ := 0; { Release the Option key }
- end;
- end
- else
- begin
- { Display an Alert : Not enough memory to open Help DA }
- end
- end {Help is Available }
- else
- begin
- { Display an Alert : Help DA not available }
- end; { End No Help Available}
- main := error; {for function result}
- end; {of GetHelp ( message ) function }
- end.